<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .fa {
            height: 100px;
        }

        .left {
            width: 200px;
            height: 100%;
            float: left;
            background: #ff0;
            position: relative;
        }

        .center {
            margin: 0 200px;
            height: 100%;
            background: #0f0;
            position: relative;
        }

        .center_1,
        .right1,
        .left1 {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
        }

        .img {
            width: 50px;
            height: 50px;
            background-color: red;
        }

        .right {
            width: 200px;
            height: 100%;
            float: right;
            background-color: aliceblue;
            position: relative;
        }
    </style>
</head>

<body>
    <script>
        /*
          3. 实现安全的对象嵌套属性值读取方法，属性不存在则返回undefined或可自定义默认兜底值
        */
        var deelyNestObj = {
            a: {
                b: {
                    c: {
                        d: 123
                    }
                }
            }
        }

        function safeGet(obj, param) {
            let show
            if(typeof obj === 'object') {
                let newparam = [...new Set(param.split('.'))]
                console.log("---", obj, newparam)
                for(let i in obj) {
                    console.log("888", i , obj[i])
                    console.log(newparam.indexOf(i) >= 0)
                    if(typeof obj[i] === 'object') safeGet(obj[i], param)
                }
            }
        }


        // safeGet(deelyNestObj, 'a.b.c.c', 'Alipay') //123
        safeGet(deelyNestObj, 'a.b..c..d ') //123
        // safeGet(deelyNestObj, 'a.b.c1.d')  //undefined
        // safeGet(deelyNestObj, 'a.b.c1.d', 'Alipay')  //Alipay
        // safeGet(deelyNestObj, 'a.b.c.d.e.f.g.h') //undefined

    </script>
    <div class="fa">
        <div class="left">
            <div class="left1 img"> </div>
        </div>
        <div class="right">
            <div class="right1"> > </div>
        </div>
        <div class="center">
            <div class="center_1">
                <div> title </div>
                <div> content </div>
            </div>
        </div>
    </div>
</body>

</html>